/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wf.model;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import wf.units.DatabaseUnit;

/**
 *
 * @author bennyl
 */
@DatabaseTable(tableName="valves")
public class Valve{
//
//    public static final String ID = "id";
//    public static final String NAME = "name";
//    public static final String PLC_ID = "plcId";
//    public static final String PORT_NUM = "portNum";

    @DatabaseField(generatedId=true)
    private int id = -1;

    @DatabaseField(canBeNull=false)
    private String name = "";

    @DatabaseField(canBeNull=false)
    private String plcIp = "";

    @DatabaseField(canBeNull=false)
    private short portNum = 0;

    public Valve() {
    }

    public Valve(int id, String name, String plcIp, short portNum) {
        this.id = id;
        this.name = name;
        this.plcIp = plcIp;
        this.portNum = portNum;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPlcIp() {
        return plcIp;
    }

    public void setPlcIp(String plcIp) {
        this.plcIp = plcIp;
    }

    public short getPortNum() {
        return portNum;
    }

    public void setPortNum(short portNum) {
        this.portNum = portNum;
    }

    @Override
    public String toString() {
        return getName() + "@" + DatabaseUnit.UNIT.selectItem(PLC.class, getPlcIp());
    }
    
}
